package com.aefottt.struggle_star.bean;

import org.litepal.LitePal;

import java.util.List;

public class TaskBean extends DataBean{

    public TaskBean(int listId) {
        super(listId);
    }

    public TaskBean(int listId, int dataId) {
        super(listId, dataId);
    }

    public TaskBean(int listId, String dataTitle, int rank, int isAchieved, long createTime,
                    long achievedTime, long deadTime, long reminderTime, int importantLevel) {
        super(listId, dataTitle, rank, isAchieved, createTime, achievedTime, deadTime, reminderTime, importantLevel);
    }

    public List<SubTaskBean> getSubTasks(){
        return LitePal.where("taskId = ?", String.valueOf(getDataId()))
                .order("rank asc").find(SubTaskBean.class);
    }

    public void deleteSubTasks(){
        LitePal.deleteAll(SubTaskBean.class, "taskId = ?", String.valueOf(getDataId()));
    }
}
